package person.bing.fbcloud.leetcode;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: mengfanbing
 * @date: 2020/10/9 9:48
 */
public class Q141 {
    public static void main(String[] args) {
    }

    public static boolean hasCycle(ListNode head) {
        List<ListNode> temp = new ArrayList<>();
        while (head != null){
            if (temp.contains(head)){
                return true;
            }else {
                temp.add(head);
                head = head.next;
            }
        }
        return false;
    }

    class ListNode {
        int val;
        ListNode next;
        ListNode(int x) {
            val = x;
            next = null;
        }
    }


}

